package com.lagou.hdfs;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * ClassName: SortReduce <br/>
 * Description: <br/>
 * date: 2020/9/1 3:47 下午<br/>
 *
 * @author colde<br />
 */
public class SortReduce extends Reducer<LongWritable, NullWritable,LongWritable,LongWritable> {

    final AtomicInteger ranking = new AtomicInteger(1);
    final LongWritable longWritable = new LongWritable();

    @Override
    protected void reduce(LongWritable key, Iterable<NullWritable> values, Context context) throws IOException, InterruptedException {
        longWritable.set(ranking.getAndIncrement());
        context.write(longWritable,key);
    }
}
